<?php
class SloggyComments extends Slog_Db_Table 
{
	public function __create()
	{
		$this->query(<<<EOD
		CREATE TABLE `sloggy_comments` (
		  `id` int(10) unsigned NOT NULL auto_increment,
		  `id_post` int(10) unsigned NOT NULL,
		  `nick` varchar(100) NOT NULL,
		  `email` varchar(150) NOT NULL,
		  `web` varchar(150) NOT NULL,
		  `body` text NOT NULL,
		  `date` int(10) unsigned NOT NULL,
		  PRIMARY KEY  (`id_comment`)
		);
EOD
		);
	}
	
	public function getByPostId($id_post)
	{
		$id_post = @intval($id_post);
		$sql = "
			SELECT *
			FROM {$this->getName()}
			WHERE id_post = $id_post
		";
		return $this->fetchAll($sql);
	}
}